import { api } from '../api';
import type { AppRequestParams, ApplicationTable } from './types/applicationTypes';

export const getApplicationTable = async (params: AppRequestParams): Promise<ApplicationTable> => {
  try {
    const response = await api.get<ApplicationTable>('/java/ground/camp_app/get', {
      params: {
        page: params.page,
        size: params.size,
        keywords: params.keywords,
        camp: params.camp,
        tag: params.tag,
      },
    });
    return response.data; // 返回后端响应的数据
  }
  catch (error) {
    console.error('Error fetching artworks:', error);
    throw error; // 抛出错误以便后续处理
  }
};

export const getCommonAppTags = async () => {
  try {
    const response = await api.get("/java/ground/camp_app/tags");
    return response.data;
  }
  catch (error) {
    throw new Error("用户信息请求失败");
  }
};
